class Watcher {
  constructor() {
    this.watchers = []
  }
  addWatcher (vm, watcher, key) {
    this._addWatcherProp({
      key,
      fn: watcher[key].bind(vm)
    })
  }

  invoke (key, newValue, oldValue) {
    this.watchers.map(item => {
      if(item.key === key){
       item.fn(newValue, oldValue);
      }
    })
  }

  _addWatcherProp (watcherProp) {
    this.watchers.push(watcherProp)
  }
}

export default Watcher
